<template>
    <el-aside :width="isCollapse?'80px':'200px'">
      <el-radio-group v-model="isCollapse" style="margin-bottom: 36px">
          <el-radio-button :value="isCollapse?false:true">
              <el-icon  color="#2e537d" style="width: 50px;" background-color="#2e537d"><Expand /></el-icon>
          </el-radio-button>
     </el-radio-group> 
  <el-menu
  :router="true" 
  active-color="#ffd04b"
  background-color="#2e537d"
  text-color="#fff"
    default-active="$route.path"
    class="el-menu-vertical-demo"
    :collapse="isCollapse"
    @open="handleOpen"
    @close="handleClose"
  >
  <el-menu-item  v-for="v in navMenu" :key="v.path" :index="v.path">
    <el-icon><icon-menu /></el-icon>
    <span>{{ v.meta.title }}</span>
    </el-menu-item>

    <!--<el-sub-menu index="1">
      <template #title>
        <el-icon><location /></el-icon>
        <span>Navigator One</span>
      </template>
      <el-menu-item-group>
        <template #title><span>Group One</span></template>
        <el-menu-item index="1-1">item one</el-menu-item>
        <el-menu-item index="1-2">item two</el-menu-item>
      </el-menu-item-group>
      <el-menu-item-group title="Group Two">
        <el-menu-item index="1-3">item three</el-menu-item>
      </el-menu-item-group>
      <el-sub-menu index="1-4">
        <template #title><span>item four</span></template>
        <el-menu-item index="1-4-1">item one</el-menu-item>
      </el-sub-menu>
    </el-sub-menu>
    <el-menu-item index="2">
      <el-icon><icon-menu /></el-icon>
      <template #title>Navigator Two</template>
    </el-menu-item>
    <el-menu-item index="3" disabled>
      <el-icon><document /></el-icon>
      <template #title>Navigator Three</template>
    </el-menu-item>
    <el-menu-item index="4">
      <el-icon><setting /></el-icon>
      <template #title>Navigator Four</template>
    </el-menu-item>-->
  </el-menu>
</el-aside>
</template>

<script setup lang="ts">
import {
  Document,
  Menu as IconMenu,
  Location,
  Setting,
} from '@element-plus/icons-vue'

import {ref,onMounted} from "vue"
import type { INavMenu } from "@/api/type";
import {getUserinfo,getRouters} from '@/api/index.ts'
const navMenu=ref<INavMenu[]>([] as INavMenu[]);

onMounted(async()=>{
  //let res=await getUserinfo();
 // console.table("用户信息:"+res.data)

  let {data}=await getRouters();
   navMenu.value=data.data;
}

)
const isCollapse = ref(false)
const handleOpen = (key: string, keyPath: string[]) => {
  console.log(key, keyPath)
}
const handleClose = (key: string, keyPath: string[]) => {
  console.log(key, keyPath)
}
</script>

<style scoped>
.el-menu-vertical-demo:not(.el-menu--collapse) {
  width: 200px;
  min-height: 400px;
}
.el-radio-button__inner{
  background-color: red;
}
</style>